<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Optimal doping profile optimization with current gain constraint.</title>
<link rel="canonical" href="http://cvxr.com/cvx/examples/gp_tutorial/html/beta_min_odp.html">
<link rel="stylesheet" href="../../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Optimal doping profile optimization with current gain constraint.</h1>
Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#output">Text output</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#plots">Plots</a>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../index.html">Library index</a>
</div>
<div id="content">
<a id="source"></a>
<pre class="codeinput">
<span class="comment">% Boyd, Kim, Vandenberghe, and Hassibi, "A tutorial on geometric programming"</span>
<span class="comment">% Joshi, Boyd, and Dutton, "Optimal doping profiles via geometric programming"</span>
<span class="comment">% Written for CVX by Almir Mutapcic 02/08/06</span>
<span class="comment">% (a figure is generated)</span>
<span class="comment">%</span>
<span class="comment">% Determines the optimal doping profile that minimizes base transit</span>
<span class="comment">% time subject to a lower bound constraint on the current gain (beta).</span>
<span class="comment">% This problem can be posed as a GP:</span>
<span class="comment">%</span>
<span class="comment">%   minimize   tau_B</span>
<span class="comment">%       s.t.   Nmin &lt;= v &lt;= Nmax</span>
<span class="comment">%              y_(i+1) + v_i^const1 &lt;= y_i</span>
<span class="comment">%              w_(i+1) + v_i^const2 &lt;= w_i, etc...</span>
<span class="comment">%              beta =&gt; beta_min</span>
<span class="comment">%</span>
<span class="comment">% where variables are v_i, y_i, and w_i.</span>

<span class="comment">% problem size</span>
M = 20;

<span class="comment">% problem constants</span>
g1 = 0.42;
g2 = 0.69;
Nmax = 5*10^18;
Nmin = 5*10^16;
Nref = 10^17;
Dn0 = 20.72;
ni0 = 1.4*(10^10);
WB = 10^(-5);
C =  WB^2/((M^2)*(Nref^g1)*Dn0);

<span class="comment">% minimum current gain values</span>
beta_min_GE = [1 1.4 1.8 2.2 2.6 3.0 3.4 3.43]*(1e-11);

<span class="comment">% exponent powers</span>
pwi = g2 -1;
pwj = 1+g1-g2;

v_array = [];
<span class="keyword">for</span> k = 1:length(beta_min_GE)
    fprintf( <span class="string">'beta_min_GE = %g: '</span>, beta_min_GE(k) );
    cvx_begin <span class="string">gp</span> <span class="string">quiet</span>
        <span class="comment">% optimization variables</span>
        variables <span class="string">v(M)</span> <span class="string">y(M)</span> <span class="string">w(M)</span>

        <span class="comment">% objective function is the base transmit time</span>
        tau_B = C*w(1);

        minimize( tau_B )
        subject <span class="string">to</span>
        <span class="comment">% fixed problem constraints</span>
        Nmin &lt;= v &lt;= Nmax;

        <span class="keyword">for</span> i=1:M-1
            y(i+1) + v(i)^pwj &lt;= y(i);
            w(i+1) + y(i)*v(i)^pwi &lt;= w(i);
        <span class="keyword">end</span>

        <span class="comment">% equalities</span>
        y(M) == v(M)^pwj;
        w(M) == y(M)*v(M)^pwi;

        <span class="comment">% changing constraint</span>
        (WB*beta_min_GE(k)/(M*Nref^(g1-g2)*Dn0))*y(1) &lt;= 1;
    cvx_end
    fprintf( <span class="string">'%s\n'</span>, cvx_status );
    <span class="comment">% keep the optimal solution</span>
    v_array = [v_array v];
<span class="keyword">end</span>

<span class="comment">% plot the basic optimal doping profile</span>
figure, clf
nbw = 0:1/M:1-1/M;
<span class="keyword">for</span> k = 1:length(beta_min_GE)
  semilogy(nbw,v_array(:,k),<span class="string">'LineWidth'</span>,2); hold <span class="string">on</span>;
<span class="keyword">end</span>
axis([0 1 1e16 1e19]);
xlabel(<span class="string">'base'</span>);
ylabel(<span class="string">'doping'</span>);
text(0,Nmin,<span class="string">'Nmin '</span>, <span class="string">'HorizontalAlignment'</span>,<span class="string">'right'</span>);
text(0,Nmax,<span class="string">'Nmax '</span>, <span class="string">'HorizontalAlignment'</span>,<span class="string">'right'</span>);
hold <span class="string">off</span>;
</pre>
<a id="output"></a>
<pre class="codeoutput">
beta_min_GE = 1e-11: Solved
beta_min_GE = 1.4e-11: Solved
beta_min_GE = 1.8e-11: Solved
beta_min_GE = 2.2e-11: Solved
beta_min_GE = 2.6e-11: Solved
beta_min_GE = 3e-11: Solved
beta_min_GE = 3.4e-11: Solved
beta_min_GE = 3.43e-11: Solved
</pre>
<a id="plots"></a>
<div id="plotoutput">
<img src="beta_min_odp__01.png" alt=""> 
</div>
</div>
</body>
</html>